import MPopup from './m-popup/index.js'
import MReadMore from './m-read-more/index.js'
import MDescription from './m-description/index.js'
import MTable from './m-table/index.js'
import MChart from './m-chart/index.js'
import MGraph from './m-graph/index.js'

// 拼接组件名称
function extractComps(comps) {
  const newCompsMap = {}
  Object.keys(comps).forEach((compName) => {
    const compsMap = comps[compName]
    Object.keys(compsMap).forEach((key) => {
      // 如果key为Index，则不拼接到名字上
      newCompsMap[`${compName}${key === 'Index' ? '' : key}`] = compsMap[key]
    })
  })
  return newCompsMap
}

const components = {
  ...extractComps({
    MPopup,
    MReadMore,
    MDescription,
    MTable,
    MChart,
    MGraph,
  }),
}

export default components
